package com.hehe.controller;


import com.hehe.POJO.T_user;
import com.hehe.Repository.T_User_Repository;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Optional;

@Controller
@RequestMapping(value = "testttttt")
public class Aaaaaaaaaaaa {

    @Value("${config_file_name}")
    private String config_file_name;

    @Resource
    private T_User_Repository t_user_repository;


    //   不要带斜杠 / , Linux 下面会报错


    //   @GetMapping("/users/{id}") 中的 id 可以通过 @PathVariable Long id 来获取
    //    ResponseBody
    //   不要带斜杠 / , Linux 下面会报错
    @GetMapping("/{id}")
    @ResponseBody
    public String ResponseBody_test(@PathVariable Long id, Model model) {
        return "ResponseBody----test---TEST----测试测试测试.....";
    }


    //   不要带斜杠 / , Linux 下面会报错
    //  获取 /api/users/updateName?id=123&newName=John
    @GetMapping(value = "user/{id}")
    @ResponseBody
    public String User(Model model,
                       @PathVariable Long id,
                       @RequestParam(defaultValue = "aaa", required = false) String typee,
                       @RequestParam(defaultValue = "aaa", required = false) String city) {
        Optional<T_user> user = t_user_repository.findById(id);
        return user.toString();
    }



}

